package com.example.demo.Controller;

import com.example.demo.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

//
//@Controller
//@ResponseBody
@RestController //和上面两个等价
@RequestMapping("/user")
public class UserController {


//    @Value("${myGirlFriend.name}")
//    private String name;

    @Autowired
    private User user;

    //随着SpringBoot的加载而加载
    @PostConstruct
    public void doPostConstruct() {
//        System.out.println("----------- ——> name: " + name);
        System.out.println(user.toString());
    }
}
